package com.cn.coupon;

import com.cn.coupon.service.CouponService;
import com.cn.dto.CouponDTO;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;

@RunWith(SpringRunner.class)
@SpringBootTest
public class Coupon {
        @Resource
        private CouponService couponService;

//    @Test
//    public void test() throws IOException {
//        PagingDTO pagingDTO = new PagingDTO(3,2);
//        List<CouponDTO> all = couponMapper.findAllCoupon(pagingDTO);
//        System.out.println(all);
//    }
//
//    @Test
//    public void test1() {
//        CouponDTO byId = couponMapper.findById(1);
//        System.out.println(byId);
//    }
//
//    @Test
//    public void test2() throws IOException {
//        Status byStatus = couponMapper.findByStatus(0);
//        System.out.println(byStatus);
//    }

    @Test
    public void test3() throws IOException {
        CouponDTO couponDTO = new CouponDTO();
        BigDecimal bigDecimal = new BigDecimal("60");
        couponDTO.setCoupon_id(1005);
        couponDTO.setImg(" ");
        couponDTO.setName("六一儿童欢乐大放送");
        couponDTO.setType("折扣券");
        couponDTO.setCount(200);
        couponDTO.setStatus(0);
        couponDTO.setCreate_time("2022-01-02 08:00:00");
        couponDTO.setUpdate_time("2022-02-28 00:00:00");
        couponDTO.setStart_time("2022-02-28 00:00:00");
        couponDTO.setEnd_time("2022-02-28 00:00:00");
        couponDTO.setCoupon_amount(bigDecimal);
        couponDTO.setExplain("每人限领一次，优惠券不可叠加使用，不可转增他人");
        couponDTO.setEffective_time("2022-06-1 00:00:00——2022-06-07 23:59:59");
        int coupon = couponService.createCoupon(couponDTO);
        System.out.println(coupon);
    }

    @Test
    public void test4() throws IOException {

        CouponDTO couponDTO = new CouponDTO();
        BigDecimal bigDecimal = new BigDecimal("60");
        couponDTO.setId(3);
        couponDTO.setImg("讲话稿讲话稿");
        couponDTO.setName("双十一狂欢");
        couponDTO.setType("折扣券");
        couponDTO.setCount(200);
        couponDTO.setStart_time("2022-02-28 00:00:00");
        couponDTO.setEnd_time("2022-02-28 00:00:00");
        couponDTO.setCoupon_amount(bigDecimal);
        couponDTO.setExplain("每人限领一次，优惠券不可叠加使用，不可转增他人");
        couponDTO.setEffective_time("2022-06-1 00:00:00——2022-06-07 23:59:59");
        Integer integer = couponService.editCoupon(couponDTO);
        System.out.println(integer);
    }

    @Test
    public void test5() throws IOException {
        Integer integer = couponService.deleteCoupon(6);
        System.out.println(integer);
    }

    @Test
    public void test6() throws IOException {
        Integer enable = couponService.enable(1);
        System.out.println(enable);
    }

//    @Test
//    public void test7() throws IOException {
//        Detailed byNumber = couponMapper.findByNumber("202201289965213");
//        System.out.println(byNumber);
//    }
//
    @Test
    public void test8() throws IOException {
        CouponDTO byState = couponService.findByState(2);
        System.out.println(byState);
    }
}
